#ifndef __MSG_PACK_H_
#define __MSG_PACK_H_

typedef enum{
    PACK_LOGIN,PACK_LOGIN_RET,
    PACK_REG,PACK_REG_RET,
    PACK_DEVLIST,PACK_DEVLIST_RET,
    PACK_DEV_ADD,PACK_DEV_ADD_RET,
    PACK_DEV_DEL,PACK_DEV_DEL_RET,
    PACK_START_CAMERA,PACK_START_CAMERA_RET,
    PACK_STOP_CAMERA,PACK_STOP_CAMERA_RET,
    PACK_DEV_HEART,
    PACK_DEV_VEDIO,PACK_DEV_VEDIO_RET
}PACK_TYPE;

typedef struct nn{
    unsigned int filedLen;//本字段内容长度(不包括本字段)
    char * content;//字段内容
    struct nn* next;//下个节点的指针
}field_t;

typedef struct{
    unsigned int totalLen;//报文总长度(包括本字段)
    PACK_TYPE type;//报文类型
    unsigned int fieldNum;//字段数量
    field_t* startField; 
    field_t* endField; 
}msg_pack_t;

msg_pack_t* pack_create(PACK_TYPE type);
void pack_destroy(msg_pack_t* pack);
void pack_add_field(msg_pack_t* pack, int filedLen, char* content);
void pack_2_buf(msg_pack_t* pack, char* buf);
msg_pack_t * pack_from_socket(int fd);
field_t* pack_getField(msg_pack_t* pack, int index);



#endif